editeng/inc/ParagraphPortion.hxx    |    2 --
 editeng/source/editeng/impedit3.cxx |    2 +-
 sc/inc/scerrors.hrc                 |    2 +-
 sc/inc/scerrors.hxx                 |    1 +
 sc/inc/strings.hrc                  |    3 +++
 sc/source/filter/excel/excel.cxx    |    9 +++++++++
 sc/source/ui/docshell/docsh.cxx     |   26 +++++++++++++++++++++++---
 sc/source/ui/docshell/docshimp.hxx  |    3 +++
 8 files changed, 41 insertions(+), 7 deletions(-)

New commits:
commit 923b1ad7b7bc249838aa619361974f0e3134ab6a
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Feb 17 00:19:41 2024 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Feb 17 12:07:28 2024 +0100

    sc: Show warning for a XLS document with unknown encrypted part
    
    If a document contains a "DRMContent" section that we don't know
    how to decrypt, show a warning before showing the un-encrypted
    content.
    
    Change-Id: Id7f48b68e1d65ce46434906b2fb3c7912dcc5f49
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163513
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/inc/scerrors.hrc b/sc/inc/scerrors.hrc
index 88b099f69107..b3fc7bd01ec1 100644
--- a/sc/inc/scerrors.hrc
+++ b/sc/inc/scerrors.hrc
@@ -101,7 +101,7 @@ const ErrMsgCode RID_ERRHDLSC[] =
       SCWARN_EXPORT_NONCONVERTIBLE_CHARS },
     { NC_("RID_ERRHDLSC", "Format error discovered in the file in sub-document 
$(ARG1) at $(ARG2)(row,col)."),
       SCWARN_IMPORT_FILE_ROWCOL },
-    { NC_("RID_ERRHDLSC", "Not all attributes could be read.") ,
+    { NC_("RID_ERRHDLSC", "Not all attributes could be read."),
       SCWARN_IMPORT_FEATURES_LOST },
     { {}, ERRCODE_NONE }
 };
diff --git a/sc/inc/scerrors.hxx b/sc/inc/scerrors.hxx
index dcb734502eae..c425e2fe8862 100644
--- a/sc/inc/scerrors.hxx
+++ b/sc/inc/scerrors.hxx
@@ -47,6 +47,7 @@
 #define SCERR_IMPORT_FILE_ROWCOL    ErrCode( ErrCodeArea::Sc, 
ErrCodeClass::Read, 16 )
 #define SCERR_IMPORT_FORMAT_ROWCOL  ErrCode( ErrCodeArea::Sc, 
ErrCodeClass::Read, 17 )
 #define SCWARN_IMPORT_FILE_ROWCOL   ErrCode( WarningFlag::Yes, 
ErrCodeArea::Sc, ErrCodeClass::Read, 18 )
+#define SCWARN_IMPORT_UNKNOWN_ENCRYPTION ErrCode(WarningFlag::Yes, 
ErrCodeArea::Sc, ErrCodeClass::Read, 19)
 
 // ErrCodeClass::Write - file related, displays "Write-Error" in MsgBox
 #define SCERR_EXPORT_CONNECT        ErrCode( ErrCodeArea::Sc,  
ErrCodeClass::Write, 1 )
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 266cb4cc6c5b..070f117a001e 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -412,4 +412,7 @@
 #define STR_CONDITION_CONTAINS_TEXT                 
NC_("STR_CONDITION_CONTAINS_TEXT", "containing text")
 #define STR_CONDITION_NOT_CONTAINS_TEXT             
NC_("STR_CONDITION_NOT_CONTAINS_TEXT", "not containing text")
 
+#define STR_CONTENT_WITH_UNKNOWN_ENCRYPTION 
NC_("STR_CONTENT_WITH_UNKNOWN_ENCRYPTION", "Document contains DRM content that 
is encrypted with an unknown encryption method. Only the un-encrypted content 
will be shown.")
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx
index 3542208eb174..862e85d08545 100644
--- a/sc/source/filter/excel/excel.cxx
+++ b/sc/source/filter/excel/excel.cxx
@@ -165,6 +165,8 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& 
rMedium, ScDocument*
     SvStream* pBookStrm = nullptr;            // The "Book"/"Workbook" stream 
containing main data.
     XclBiff eBiff = EXC_BIFF_UNKNOWN;   // The BIFF version of the main stream.
 
+    bool bUnableToDecryptContent = false;
+
     // try to open an OLE storage
     tools::SvRef<SotStorage> xRootStrg;
     tools::SvRef<SotStorageStream> xStrgStrm;
@@ -186,6 +188,10 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( 
SfxMedium& rMedium, ScDocument*
             auto pDecryptedStorage = lcl_DRMDecrypt(rMedium, xRootStrg, 
aNewStorageStrm);
             if (pDecryptedStorage)
                 xRootStrg = pDecryptedStorage;
+            else
+            {
+                bUnableToDecryptContent = true;
+            }
         }
 
         // try to open the "Book" stream
@@ -250,6 +256,9 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& 
rMedium, ScDocument*
         eRet = xFilter ? xFilter->Read() : SCERR_IMPORT_INTERNAL;
     }
 
+    if (bUnableToDecryptContent && eRet == ERRCODE_NONE)
+        eRet = SCWARN_IMPORT_UNKNOWN_ENCRYPTION;
+
     return eRet;
 }
 
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 1cfd3778d6be..5f0cf927cd1d 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -48,6 +48,7 @@
 #include <sfx2/lokhelper.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/viewfrm.hxx>
+#include <sfx2/infobar.hxx>
 #include <svl/documentlockfile.hxx>
 #include <svl/fstathelper.hxx>
 #include <svl/sharecontrolfile.hxx>
@@ -775,6 +776,11 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
                         }
                     }
 #endif
+
+                    ScViewData* pViewData = GetViewData();
+                    SfxViewShell* pViewShell = pViewData ? 
pViewData->GetViewShell() : nullptr;
+                    SfxViewFrame* pViewFrame = pViewShell ? 
&pViewShell->GetViewFrame() : nullptr;
+
                     try
                     {
                         uno::Reference< uno::XComponentContext > xContext(
@@ -795,9 +801,6 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
                                 if ( xFactory.is() )
                                 {
                                     uno::Reference< task::XJob > xJob( 
xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
-                                    ScViewData* pViewData = GetViewData();
-                                    SfxViewShell* pViewShell = ( pViewData ? 
pViewData->GetViewShell() : nullptr );
-                                    SfxViewFrame* pViewFrame = ( pViewShell ? 
&pViewShell->GetViewFrame() : nullptr );
                                     SfxFrame* pFrame = ( pViewFrame ? 
&pViewFrame->GetFrame() : nullptr );
                                     uno::Reference< frame::XController > 
xController = ( pFrame ? pFrame->GetController() : nullptr );
                                     uno::Reference< sheet::XSpreadsheetView > 
xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
@@ -810,6 +813,16 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
                     catch ( uno::Exception & )
                     {
                     }
+
+                    // Show delayed infobar entries
+                    if (pViewFrame)
+                    {
+                        for (auto const& r : m_pImpl->mpDelayedInfobarEntry)
+                        {
+                            pViewFrame->AppendInfoBar(r.msId, 
r.msPrimaryMessage, r.msSecondaryMessage, r.maInfobarType, r.mbShowCloseButton);
+                        }
+                        m_pImpl->mpDelayedInfobarEntry.clear();
+                    }
                 }
                 break;
             case SfxEventHintId::SaveDoc:
@@ -1259,6 +1272,13 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
             // all graphics objects must have names
             m_pDocument->EnsureGraphicNames();
 
+            if (eError == SCWARN_IMPORT_UNKNOWN_ENCRYPTION)
+            {
+
+                m_pImpl->mpDelayedInfobarEntry.push_back({ 
"UnknownEncryption", ScResId(STR_CONTENT_WITH_UNKNOWN_ENCRYPTION), "", 
InfobarType::INFO, true });
+                eError = ERRCODE_NONE;
+            }
+
             if (eError != ERRCODE_NONE)
             {
                 if (!GetErrorIgnoreWarning())
diff --git a/sc/source/ui/docshell/docshimp.hxx 
b/sc/source/ui/docshell/docshimp.hxx
index 58cfb23ac70f..b6942d549db8 100644
--- a/sc/source/ui/docshell/docshimp.hxx
+++ b/sc/source/ui/docshell/docshimp.hxx
@@ -21,6 +21,7 @@
 #include <svtools/ctrltool.hxx>
 #include <sfx2/docinsert.hxx>
 #include <sfx2/request.hxx>
+#include <sfx2/infobar.hxx>
 
 struct DocShell_Impl
 {
@@ -29,6 +30,8 @@ struct DocShell_Impl
     std::unique_ptr<sfx2::DocumentInserter> pDocInserter;
     std::unique_ptr<SfxRequest>             pRequest;
 
+    std::vector<InfobarData> mpDelayedInfobarEntry;
+
     DocShell_Impl() :
           bIgnoreLostRedliningWarning( false )
     {}
commit 347890c05e689cecc9361b4c2ebd25cb3b87f8e7
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Feb 12 11:03:29 2024 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Feb 17 12:07:20 2024 +0100

    editeng: remove getHeight as a similar GetHeight already exits
    
    Change-Id: I947b736b2c1eb8a6f0155460b4dc61d504623ca2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163510
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/editeng/inc/ParagraphPortion.hxx b/editeng/inc/ParagraphPortion.hxx
index 2b0664ec0c2d..2e801a58c43d 100644
--- a/editeng/inc/ParagraphPortion.hxx
+++ b/editeng/inc/ParagraphPortion.hxx
@@ -84,8 +84,6 @@ public:
     {
     }
 
-    tools::Long getHeight() { return mnHeight; }
-
     sal_Int32 GetLineNumber(sal_Int32 nIndex) const;
 
     EditLineList& GetLines() { return maLineList; }
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 5beaaf95e434..b54e1328a0ac 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -4290,7 +4290,7 @@ void ImpEditEngine::ShowParagraph( sal_Int32 nParagraph, 
bool bShow )
         // If anyway, then save as sal_False before SetVisible !
     }
 
-    if (bShow && (pPPortion->IsInvalid() || !pPPortion->getHeight()))
+    if (bShow && (pPPortion->IsInvalid() || !pPPortion->GetHeight()))
     {
         if ( !GetTextRanger() )
         {

Reply via email to