[Libreoffice-commits] core.git: Branch 'feature/table_rotated_text' - 2 commits - oox/source sd/qa svx/source

Tamás Zolnai tamas.zolnai at collabora.com
Fri Apr 7 17:47:57 UTC 2017


 oox/source/drawingml/table/tablecell.cxx |    7 ++++
 sd/qa/unit/data/pptx/tdf100926.pptx      |binary
 sd/qa/unit/import-tests.cxx              |   28 +++++++++++++++++++
 svx/source/table/cell.cxx                |   44 +++++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+)

New commits:
commit 15e1a8c5caa2da21e820fc3c1f20dc5490e1986f
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Fri Apr 7 14:17:57 2017 +0200

    tdf#100926: PPTX import of table with rotated text
    
    Change-Id: I05a8e979ac11b179e15784023032a56edc5b569b

diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx
index 1c0d08616599..2501a6cd2d45 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -467,6 +467,13 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons
     }
 
     getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, pMasterTextListStyle );
+
+    if (getVertToken() == XML_vert)
+        xPropSet->setPropertyValue("RotateAngle", Any(short(27000)));
+    else if (getVertToken() == XML_vert270)
+        xPropSet->setPropertyValue("RotateAngle", Any(short(9000)));
+    else
+        xPropSet->setPropertyValue("RotateAngle", Any(short(0)));
 }
 
 } } }
diff --git a/sd/qa/unit/data/pptx/tdf100926.pptx b/sd/qa/unit/data/pptx/tdf100926.pptx
new file mode 100755
index 000000000000..71627394ec84
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf100926.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index f45ae187d0db..881a43de6928 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -145,6 +145,7 @@ public:
     void testTdf104445();
     void testTdf105150();
     void testTdf105150PPT();
+    void testTdf100926();
 
     bool checkPattern(sd::DrawDocShellRef& rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
     void testPatternImport();
@@ -210,6 +211,7 @@ public:
     CPPUNIT_TEST(testTdf104445);
     CPPUNIT_TEST(testTdf105150);
     CPPUNIT_TEST(testTdf105150PPT);
+    CPPUNIT_TEST(testTdf100926);
     CPPUNIT_TEST(testPatternImport);
 
     CPPUNIT_TEST_SUITE_END();
@@ -2189,6 +2191,32 @@ void SdImportTest::testPatternImport()
     xDocRef->DoClose();
 }
 
+void SdImportTest::testTdf100926()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf100926.pptx"), PPTX);
+    const SdrPage* pPage = GetPage(1, xDocShRef);
+    CPPUNIT_ASSERT(pPage != nullptr);
+
+    sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
+    CPPUNIT_ASSERT(pTableObj != nullptr);
+    uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
+
+    sal_Int32 nRotation = 0;
+    uno::Reference< beans::XPropertySet > xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
+    xCell->getPropertyValue("RotateAngle") >>= nRotation;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation);
+
+    xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
+    xCell->getPropertyValue("RotateAngle") >>= nRotation;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation);
+
+    xCell.set(xTable->getCellByPosition(2, 0), uno::UNO_QUERY_THROW);
+    xCell->getPropertyValue("RotateAngle") >>= nRotation;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation);
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index ae4daa76affa..3096ee6948aa 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -334,6 +334,22 @@ namespace sdr
                 const SvxTextRotateItem* pRotateItem = static_cast<const SvxTextRotateItem*>(pNewItem);
                 SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject());
                 rObj.SetVerticalWriting(pRotateItem->IsVertical(), true, pRotateItem->IsTopToBottom());
+
+                // Set a cell vertical property
+                OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
+
+                const bool bOwnParaObj = pParaObj != nullptr;
+
+                if (pParaObj == nullptr)
+                    pParaObj = mxCell->GetOutlinerParaObject();
+
+                if (pParaObj)
+                {
+                    pParaObj->SetVertical(pRotateItem->IsVertical(), pRotateItem->IsTopToBottom());
+
+                    if (bOwnParaObj)
+                        delete pParaObj;
+                }
             }
 
             // call parent
commit 76651ebf109d6841240a1d90f708893106d148d9
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Thu Apr 6 22:22:53 2017 +0200

    Implement RotateAngle API property for Impress table cells
    
    Change-Id: I01379c0fc21e8fe294bc882bf824f64502863ff4

diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index ead3e2ab3d78..ae4daa76affa 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -90,6 +90,7 @@ static const SvxItemPropertySet* ImplGetSvxCellPropertySet()
         { OUString("BottomBorder"),                 SDRATTR_TABLE_BORDER,           cppu::UnoType<BorderLine>::get(), 0, BOTTOM_BORDER },
         { OUString("LeftBorder"),                   SDRATTR_TABLE_BORDER,           cppu::UnoType<BorderLine>::get(), 0, LEFT_BORDER },
         { OUString("RightBorder"),                  SDRATTR_TABLE_BORDER,           cppu::UnoType<BorderLine>::get(), 0, RIGHT_BORDER },
+        { OUString("RotateAngle"),                  SDRATTR_TABLE_TEXT_ROTATION,    cppu::UnoType<sal_Int32>::get(), 0, 0 },
 
         SVX_UNOEDIT_OUTLINER_PROPERTIES,
         SVX_UNOEDIT_CHAR_PROPERTIES,
@@ -1065,6 +1066,17 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
             mpProperties->SetObjectItem( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
             return;
         }
+        case SDRATTR_TABLE_TEXT_ROTATION:
+        {
+            sal_Int32 nRotVal = 0;
+            if (!(rValue >>= nRotVal))
+                throw IllegalArgumentException();
+
+            if (nRotVal != 27000 && nRotVal != 9000 && nRotVal != 0)
+                throw IllegalArgumentException();
+
+            mpProperties->SetObjectItem(SvxTextRotateItem(nRotVal/10, SDRATTR_TABLE_TEXT_ROTATION));
+        }
         default:
         {
             SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
@@ -1180,6 +1192,11 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
                 return Any(  BitmapMode_NO_REPEAT );
             }
         }
+        case SDRATTR_TABLE_TEXT_ROTATION:
+        {
+            const SvxTextRotateItem& rTextRotate = static_cast<const SvxTextRotateItem&>(mpProperties->GetItem(SDRATTR_TABLE_TEXT_ROTATION));
+            return Any(sal_Int32(rTextRotate.GetValue() * 10));
+        }
         default:
         {
             SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
@@ -1472,6 +1489,12 @@ void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName )
             break;
         }
 
+        case SDRATTR_TABLE_TEXT_ROTATION:
+        {
+            mpProperties->ClearObjectItem(SDRATTR_TABLE_TEXT_ROTATION);
+            break;
+        }
+
         default:
         {
             mpProperties->ClearObjectItem( pMap->nWID );
@@ -1512,6 +1535,11 @@ Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName )
             return Any( aBorder );
         }
 
+        case SDRATTR_TABLE_TEXT_ROTATION:
+        {
+            return Any(sal_Int32(0));
+        }
+
         default:
         {
             if( SfxItemPool::IsWhich(pMap->nWID) )


More information about the Libreoffice-commits mailing list