[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra] sheets: more print settings to odf/
From:       Tomas Mecir <mecirt () gmail ! com>
Date:       2016-03-06 17:21:13
Message-ID: E1accMj-0005vS-I3 () scm ! kde ! org
[Download RAW message or body]

Git commit c563f7e0c050a2525bcc1248d69b07dda7da7c64 by Tomas Mecir.
Committed on 05/03/2016 at 19:02.
Pushed by mecir into branch 'master'.

more print settings to odf/

M  +0    -72   sheets/PrintSettings.cpp
M  +0    -19   sheets/PrintSettings.h
M  +0    -1    sheets/RowColumnFormat.h
M  +1    -1    sheets/Sheet.cpp
M  +8    -8    sheets/StyleStorage.cpp
M  +1    -2    sheets/StyleStorage.h
M  +1    -1    sheets/Util.h
M  +1    -1    sheets/Value.h
M  +76   -4    sheets/odf/SheetsOdfSheet.cpp

http://commits.kde.org/calligra/c563f7e0c050a2525bcc1248d69b07dda7da7c64

diff --git a/sheets/PrintSettings.cpp b/sheets/PrintSettings.cpp
index e582c49..81f301c 100644
--- a/sheets/PrintSettings.cpp
+++ b/sheets/PrintSettings.cpp
@@ -28,7 +28,6 @@
 #include "Region.h"
 
 // Calligra
-#include <KoGenStyles.h>
 #include <KoPageLayout.h>
 #include <KoUnit.h>
 
@@ -339,77 +338,6 @@ void PrintSettings::setRepeatedRows(const QPair<int, int>& \
repeatedRows)  d->repeatedRows = repeatedRows;
 }
 
-QString PrintSettings::saveOdfPageLayout(KoGenStyles &mainStyles,
-        bool formulas, bool zeros)
-{
-    // Create a page layout style.
-    // 15.2.1 Page Size
-    // 15.2.4 Print Orientation
-    // 15.2.5 Margins
-    KoGenStyle pageLayout = d->pageLayout.saveOdf();
-
-    // 15.2.13 Print
-    QString printParameter;
-    if (d->printHeaders) {
-        printParameter = "headers ";
-    }
-    if (d->printGrid) {
-        printParameter += "grid ";
-    }
-    /*    if (d->printComments) {
-            printParameter += "annotations ";
-        }*/
-    if (d->printObjects) {
-        printParameter += "objects ";
-    }
-    if (d->printCharts) {
-        printParameter += "charts ";
-    }
-    /*    if (d->printDrawings) {
-            printParameter += "drawings ";
-        }*/
-    if (formulas) {
-        printParameter += "formulas ";
-    }
-    if (zeros) {
-        printParameter += "zero-values ";
-    }
-    if (!printParameter.isEmpty()) {
-        printParameter += "drawings"; //default print style attributes in OO
-        pageLayout.addProperty("style:print", printParameter);
-    }
-
-    // 15.2.14 Print Page Order
-    const QString pageOrder = (d->pageOrder == LeftToRight) ? "ltr" : "ttb";
-    pageLayout.addProperty("style:print-page-order", pageOrder);
-
-    // 15.2.16 Scale
-    // FIXME handle cases where only one direction is limited
-    if (d->pageLimits.width() > 0 && d->pageLimits.height() > 0) {
-        const int pages = d->pageLimits.width() * d->pageLimits.height();
-        pageLayout.addProperty("style:scale-to-pages", pages);
-    } else if (d->zoom != 1.0) {
-        pageLayout.addProperty("style:scale-to", qRound(d->zoom * 100)); // in %
-    }
-
-    // 15.2.17 Table Centering
-    if (d->centerHorizontally && d->centerVertically) {
-        pageLayout.addProperty("style:table-centering", "both");
-    } else if (d->centerHorizontally) {
-        pageLayout.addProperty("style:table-centering", "horizontal");
-    } else if (d->centerVertically) {
-        pageLayout.addProperty("style:table-centering", "vertical");
-    } else {
-        pageLayout.addProperty("style:table-centering", "none");
-    }
-
-    // this is called from Sheet::saveOdfSheetStyleName for writing the SytleMaster \
                so
-    // the style has to be in the styles.xml file and only there
-    pageLayout.setAutoStyleInStylesDotXml(true);
-
-    return mainStyles.insert(pageLayout, "pm");
-}
-
 void PrintSettings::operator=(const PrintSettings & other)
 {
     d->pageLayout = other.d->pageLayout;
diff --git a/sheets/PrintSettings.h b/sheets/PrintSettings.h
index 7b4058b..158de32 100644
--- a/sheets/PrintSettings.h
+++ b/sheets/PrintSettings.h
@@ -223,25 +223,6 @@ public:
     void setRepeatedRows(const QPair<int, int>& repeatedRows);
 
     /**
-     * Saves a page layout style.
-     * Adds the style to \p mainStyles.
-     * Saved OpenDocument properties:
-     * \li 15.2.1 Page Size
-     * \li 15.2.4 Print Orientation
-     * \li 15.2.5 Margins
-     * \li 15.2.13 Print
-     * \li 15.2.14 Print Page Order
-     * \li 15.2.16 Scale
-     * \li 15.2.17 Table Centering
-     * \param mainStyles generic styles
-     * \param formulas print formulas
-     * \param zeros print zero values
-     * \return the style's name
-     * \ingroup OpenDocument
-     */
-    QString saveOdfPageLayout(KoGenStyles &mainStyles, bool formulas, bool zeros);
-
-    /**
      * Assignment operator.
      */
     void operator=(const PrintSettings& settings);
diff --git a/sheets/RowColumnFormat.h b/sheets/RowColumnFormat.h
index 076e541..5043c05 100644
--- a/sheets/RowColumnFormat.h
+++ b/sheets/RowColumnFormat.h
@@ -54,7 +54,6 @@ public:
 
     QDomElement save(QDomDocument&, int yshift = 0) const;
     bool load(const KoXmlElement& row, int yshift = 0, Paste::Mode mode = \
                Paste::Normal);
-    bool loadOdf(const KoXmlElement& row, KoXmlElement * rowStyle);
 
     /**
      * \return the row's height
diff --git a/sheets/Sheet.cpp b/sheets/Sheet.cpp
index c145374..1e0aee3 100644
--- a/sheets/Sheet.cpp
+++ b/sheets/Sheet.cpp
@@ -205,7 +205,7 @@ Sheet::Sheet(const Sheet &other)
     // flake
 #if 0 // CALLIGRA_SHEETS_WIP_COPY_SHEET_(SHAPES)
     //FIXME This does not work as copySettings does not work. Also \
                createDefaultShapeAndInit without the correct settings can not work
-    //I think this should use saveOdf and loadOdf for copying
+    //I think this should use ODF load/save for copying
     KoShape* shape;
     const QList<KoShape*> shapes = other.d->shapes;
     for (int i = 0; i < shapes.count(); ++i) {
diff --git a/sheets/StyleStorage.cpp b/sheets/StyleStorage.cpp
index 95fc871..8d76b6c 100644
--- a/sheets/StyleStorage.cpp
+++ b/sheets/StyleStorage.cpp
@@ -32,7 +32,6 @@
 
 #include "Global.h"
 #include "Map.h"
-#include "OdfSavingContext.h"
 #include "RTree.h"
 #include "Style.h"
 #include "StyleManager.h"
@@ -296,7 +295,8 @@ QRect StyleStorage::usedArea() const
     return QRect(QPoint(1, 1), d->usedArea.boundingRect().bottomRight());
 }
 
-void StyleStorage::saveOdfCreateDefaultStyles(int& maxCols, int& maxRows, \
OdfSavingContext& tableContext) const +// craete default styles in the style tables - \
used in Odf saving +void StyleStorage::saveCreateDefaultStyles(int& maxCols, int& \
maxRows, QMap<int, Style> &columnDefaultStyles, QMap<int, Style> &rowDefaultStyles) \
const  {
     d->ensureLoaded();
 #if 0 // TODO
@@ -304,11 +304,11 @@ void StyleStorage::saveOdfCreateDefaultStyles(int& maxCols, \
int& maxRows, OdfSav  if (!d->usedColumns.isEmpty() && !d->usedRows.isEmpty()) {
         for (int i = 0; i < d->usedColumns.count(); ++i) {
             const int col = d->usedColumns[i];
-            tableContext.columnDefaultStyles[col].insertSubStyle(contains(QRect(col, \
1, 1, KS_rowMax))); +            \
columnDefaultStyles[col].insertSubStyle(contains(QRect(col, 1, 1, KS_rowMax)));  }
         for (int i = 0; i < d->usedRow.count(); ++i) {
             const int row = d->usedRow[i];
-            tableContext.rowDefaultStyles[row].insertSubStyle(contains(QRect(1, row, \
KS_colMax, 1))); +            rowDefaultStyles[row].insertSubStyle(contains(QRect(1, \
row, KS_colMax, 1)));  }
         return;
     }
@@ -330,18 +330,18 @@ void StyleStorage::saveOdfCreateDefaultStyles(int& maxCols, \
int& maxRows, OdfSav  if (rect.top() == 1 && rect.bottom() == maxRows) {
             for (int col = rect.left(); col <= rect.right(); ++col) {
                 if (pairs[i].second.data()->type() == Style::DefaultStyleKey)
-                    tableContext.columnDefaultStyles.remove(col);
+                    columnDefaultStyles.remove(col);
                 else
-                    \
tableContext.columnDefaultStyles[col].insertSubStyle(pairs[i].second); +              \
columnDefaultStyles[col].insertSubStyle(pairs[i].second);  }
         }
         // row default cell styles
         else if (rect.left() == 1 && rect.right() == maxCols) {
             for (int row = rect.top(); row <= rect.bottom(); ++row) {
                 if (pairs[i].second.data()->type() == Style::DefaultStyleKey)
-                    tableContext.rowDefaultStyles.remove(row);
+                    rowDefaultStyles.remove(row);
                 else
-                    \
tableContext.rowDefaultStyles[row].insertSubStyle(pairs[i].second); +                 \
rowDefaultStyles[row].insertSubStyle(pairs[i].second);  }
         }
     }
diff --git a/sheets/StyleStorage.h b/sheets/StyleStorage.h
index b969c8b..6320615 100644
--- a/sheets/StyleStorage.h
+++ b/sheets/StyleStorage.h
@@ -34,7 +34,6 @@ namespace Calligra
 namespace Sheets
 {
 class Map;
-class OdfSavingContext;
 class Style;
 class StyleManager;
 class SubStyle;
@@ -97,7 +96,7 @@ public:
      * \return the OpenDocument column/row default cell styles
      * \ingroup OpenDocument
      */
-    void saveOdfCreateDefaultStyles(int& maxCols, int& maxRows, OdfSavingContext& \
tableContext) const; +   void saveCreateDefaultStyles(int& maxCols, int& maxRows, \
QMap<int, Style> &columnDefaultStyles, QMap<int, Style> &rowDefaultStyles) const;  
     /**
      * Returns the index of the next column-wide cell style after \p column or zero
diff --git a/sheets/Util.h b/sheets/Util.h
index 706c4c4..bfa08e8 100644
--- a/sheets/Util.h
+++ b/sheets/Util.h
@@ -135,7 +135,7 @@ namespace Odf
  * Converts an OpenDocument representation of a formula to a localized formula.
  * @param expr The expression to convert from OpenDocument format.
  * @param locale The locale to which the expression should be converted.
- * \note Use Region::loadOdf() for plain cell references.
+ * \note Use Odf::loadRegion() for plain cell references.
  */
 // TODO check visibility
 CALLIGRA_SHEETS_ODF_EXPORT QString decodeFormula(const QString& expression_, const \
                KLocale *locale = 0, const QString &namespacePrefix = QString());
diff --git a/sheets/Value.h b/sheets/Value.h
index f9803a3..6d6d7e3 100644
--- a/sheets/Value.h
+++ b/sheets/Value.h
@@ -309,7 +309,7 @@ public:
      * Returns the double quoted string value of this value.
      *
      * Same as \a asString but with double quotes around. This
-     * is needed for example in Conditions::saveOdfConditionValue
+     * is needed for example in Odf::saveConditionValue
      * to save Value strings with double quotes.
      */
     QString asStringWithDoubleQuotes() const;
diff --git a/sheets/odf/SheetsOdfSheet.cpp b/sheets/odf/SheetsOdfSheet.cpp
index 4212964..0bf994f 100644
--- a/sheets/odf/SheetsOdfSheet.cpp
+++ b/sheets/odf/SheetsOdfSheet.cpp
@@ -147,6 +147,7 @@ namespace Odf {
     void addText(const QString & text, KoXmlWriter & writer);
     void convertPart(Sheet *sheet, const QString & part, KoXmlWriter & xmlWriter);
     bool compareRows(Sheet *sheet, int row1, int row2, int maxCols, \
OdfSavingContext& tableContext); +    QString savePageLayout(PrintSettings *settings, \
KoGenStyles &mainStyles, bool formulas, bool zeros);  }
 
 // *************** Loading *****************
@@ -1073,8 +1074,7 @@ QString Odf::saveSheetStyleName(Sheet *sheet, KoGenStyles \
                &mainStyles)
     KoGenStyle pageStyle(KoGenStyle::TableAutoStyle, "table"/*FIXME I don't know if \
name is sheet*/);  
     KoGenStyle pageMaster(KoGenStyle::MasterPageStyle);
-#warning TODO new style odf
-    const QString pageLayoutName = \
sheet->printSettings()->saveOdfPageLayout(mainStyles, +    const QString \
pageLayoutName = savePageLayout(sheet->printSettings(), mainStyles,  \
                sheet->getShowFormula(),
                                    !sheet->getHideZero());
     pageMaster.addAttribute("style:page-layout-name", pageLayoutName);
@@ -1113,8 +1113,7 @@ void Odf::saveColRowCell(Sheet *sheet, int maxCols, int \
maxRows, OdfSavingContex  // calculate the column/row default cell styles
     int maxMaxRows = maxRows; // includes the max row a column default style \
occupies  // also extends the maximum column/row to include column/row styles
-#warning TODO new style odf
-    sheet->styleStorage()->saveOdfCreateDefaultStyles(maxCols, maxMaxRows, \
tableContext); +    sheet->styleStorage()->saveCreateDefaultStyles(maxCols, \
maxMaxRows, tableContext.columnDefaultStyles, tableContext.rowDefaultStyles);  if \
                (tableContext.rowDefaultStyles.count() != 0)
         maxRows = qMax(maxRows, (--tableContext.rowDefaultStyles.constEnd()).key());
     // Take the actual used area into account so we also catch shapes that are
@@ -1769,6 +1768,79 @@ void Odf::saveSheetSettings(Sheet *sheet, KoXmlWriter \
                &settingsWriter)
     settingsWriter.addConfigItem("ShowColumnNumber", sheet->getShowColumnNumber());
 }
 
+QString Odf::savePageLayout(PrintSettings *settings, KoGenStyles &mainStyles, bool \
formulas, bool zeros) +{
+    // Create a page layout style.
+    // 15.2.1 Page Size
+    // 15.2.4 Print Orientation
+    // 15.2.5 Margins
+    KoGenStyle pageLayout = settings->pageLayout().saveOdf();
+
+    // 15.2.13 Print
+    QString printParameter;
+    if (settings->printHeaders()) {
+        printParameter = "headers ";
+    }
+    if (settings->printGrid()) {
+        printParameter += "grid ";
+    }
+    /*    if (settings->printComments()) {
+            printParameter += "annotations ";
+        }*/
+    if (settings->printObjects()) {
+        printParameter += "objects ";
+    }
+    if (settings->printCharts()) {
+        printParameter += "charts ";
+    }
+    /*    if (settings->printDrawings()) {
+            printParameter += "drawings ";
+        }*/
+    if (formulas) {
+        printParameter += "formulas ";
+    }
+    if (zeros) {
+        printParameter += "zero-values ";
+    }
+    if (!printParameter.isEmpty()) {
+        printParameter += "drawings"; //default print style attributes in OO
+        pageLayout.addProperty("style:print", printParameter);
+    }
+
+    // 15.2.14 Print Page Order
+    const QString pageOrder = (settings->pageOrder() == PrintSettings::LeftToRight) \
? "ltr" : "ttb"; +    pageLayout.addProperty("style:print-page-order", pageOrder);
+
+    // 15.2.16 Scale
+    // FIXME handle cases where only one direction is limited
+    if (settings->pageLimits().width() > 0 && settings->pageLimits().height() > 0) {
+        const int pages = settings->pageLimits().width() * \
settings->pageLimits().height(); +        \
pageLayout.addProperty("style:scale-to-pages", pages); +    } else if \
(settings->zoom() != 1.0) { +        pageLayout.addProperty("style:scale-to", \
qRound(settings->zoom() * 100)); // in % +    }
+
+    // 15.2.17 Table Centering
+    if (settings->centerHorizontally() && settings->centerVertically()) {
+        pageLayout.addProperty("style:table-centering", "both");
+    } else if (settings->centerHorizontally()) {
+        pageLayout.addProperty("style:table-centering", "horizontal");
+    } else if (settings->centerVertically()) {
+        pageLayout.addProperty("style:table-centering", "vertical");
+    } else {
+        pageLayout.addProperty("style:table-centering", "none");
+    }
+
+    // this is called from Sheet::saveOdfSheetStyleName for writing the SytleMaster \
so +    // the style has to be in the styles.xml file and only there
+    pageLayout.setAutoStyleInStylesDotXml(true);
+
+    return mainStyles.insert(pageLayout, "pm");
+}
+
+
+
+
 
 }  // Sheets
 }  // Calligra


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic