summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/viewopt.hxx2
-rw-r--r--sw/qa/uibase/uiview/data/editinsection.odtbin0 -> 46133 bytes
-rw-r--r--sw/qa/uibase/uiview/uiview.cxx34
-rw-r--r--sw/source/core/text/inftxt.cxx35
-rw-r--r--sw/source/uibase/uiview/view.cxx6
-rw-r--r--sw/source/uibase/uiview/view0.cxx3
6 files changed, 76 insertions, 4 deletions
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index 1a9139ecc8d8..eff41b5be26d 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -554,7 +554,7 @@ public:
bool IsOnlineSpell() const
{
- return !m_bReadonly && m_nCoreOptions.bOnlineSpell;
+ return m_nCoreOptions.bOnlineSpell;
}
void SetOnlineSpell( bool b )
{
diff --git a/sw/qa/uibase/uiview/data/editinsection.odt b/sw/qa/uibase/uiview/data/editinsection.odt
new file mode 100644
index 000000000000..86288f1ace31
--- /dev/null
+++ b/sw/qa/uibase/uiview/data/editinsection.odt
Binary files differ
diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx
index 486219215581..5f41aa920c02 100644
--- a/sw/qa/uibase/uiview/uiview.cxx
+++ b/sw/qa/uibase/uiview/uiview.cxx
@@ -14,6 +14,8 @@
#include <comphelper/propertyvalue.hxx>
#include <comphelper/scopeguard.hxx>
#include <vcl/scheduler.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
#include <com/sun/star/frame/XDispatchHelper.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
@@ -22,7 +24,9 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/text/XParagraphCursor.hpp>
+#include <cmdid.h>
#include <unotxdoc.hxx>
#include <docsh.hxx>
#include <wrtsh.hxx>
@@ -320,6 +324,36 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, TestTdf152839_Formtext)
CPPUNIT_ASSERT_EQUAL(sal_Int32(723), nHeight);
}
+CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testEditInReadonly)
+{
+ createSwDoc("editinsection.odt");
+
+ SwDocShell* pDocShell = getSwDocShell();
+ SwView* pView = pDocShell->GetView();
+
+ pView->GetViewFrame().GetDispatcher()->Execute(SID_EDITDOC, SfxCallMode::SYNCHRON);
+
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XParagraphCursor> xParaCursor(xTextDocument->getText()->createTextCursor(),
+ uno::UNO_QUERY);
+
+ uno::Reference<view::XSelectionSupplier> xSelSupplier(xModel->getCurrentController(),
+ uno::UNO_QUERY_THROW);
+
+ xSelSupplier->select(css::uno::Any(xParaCursor));
+ std::unique_ptr<SfxPoolItem> pItem;
+ SfxItemState eState = pView->GetViewFrame().GetBindings().QueryState(FN_INSERT_TABLE, pItem);
+ //status disabled in read only content
+ CPPUNIT_ASSERT_EQUAL(SfxItemState::DISABLED, eState);
+
+ //move cursor to section
+ xParaCursor->gotoNextParagraph(false);
+ xSelSupplier->select(css::uno::Any(xParaCursor));
+ eState = pView->GetViewFrame().GetBindings().QueryState(FN_INSERT_TABLE, pItem);
+ //status default in editable section
+ CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, eState);
+}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index ec2d82be4356..f2cbbba03376 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -45,10 +45,12 @@
#include <viewopt.hxx>
#include <frmtool.hxx>
#include <fmturl.hxx>
+#include <fmteiro.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDeviceAccess.hxx>
#include <IDocumentMarkAccess.hxx>
#include <paratr.hxx>
+#include <sectfrm.hxx>
#include <rootfrm.hxx>
#include "inftxt.hxx"
#include <noteurl.hxx>
@@ -614,6 +616,30 @@ SwTransparentTextGuard::~SwTransparentTextGuard()
}
}
+static bool lcl_IsFrameReadonly(SwTextFrame* pFrame)
+{
+ const SwFlyFrame* pFly;
+ const SwSection* pSection;
+
+ if( pFrame && pFrame->IsInFly() &&
+ (pFly = pFrame->FindFlyFrame())->GetFormat()->GetEditInReadonly().GetValue() &&
+ pFly->Lower() &&
+ !pFly->Lower()->IsNoTextFrame() )
+ {
+ return false;
+ }
+ // edit in readonly sections
+ else if ( pFrame && pFrame->IsInSct() &&
+ nullptr != ( pSection = pFrame->FindSctFrame()->GetSection() ) &&
+ pSection->IsEditInReadonlyFlag() )
+ {
+ return false;
+ }
+
+ return true;
+}
+
+
void SwTextPaintInfo::DrawText_( const OUString &rText, const SwLinePortion &rPor,
TextFrameIndex const nStart, TextFrameIndex const nLength,
const bool bKern, const bool bWrong,
@@ -637,7 +663,14 @@ void SwTextPaintInfo::DrawText_( const OUString &rText, const SwLinePortion &rPo
bool bCfgIsAutoGrammar = false;
SvtLinguConfig().GetProperty( UPN_IS_GRAMMAR_AUTO ) >>= bCfgIsAutoGrammar;
const bool bBullet = OnWin() && GetOpt().IsBlank() && IsNoSymbol();
- const bool bTmpWrong = bWrong && OnWin() && GetOpt().IsOnlineSpell();
+ bool bTmpWrong = bWrong && OnWin() && GetOpt().IsOnlineSpell();
+ SfxObjectShell* pObjShell = m_pFrame->GetDoc().GetDocShell();
+ if (bTmpWrong && pObjShell)
+ {
+ if (pObjShell->IsReadOnly() && lcl_IsFrameReadonly(m_pFrame))
+ bTmpWrong = false;
+ }
+
const bool bTmpGrammarCheck = bGrammarCheck && OnWin() && bCfgIsAutoGrammar && GetOpt().IsOnlineSpell();
const bool bTmpSmart = bSmartTag && OnWin() && !GetOpt().IsPagePreview() && SwSmartTagMgr::Get().IsSmartTagsEnabled();
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index f2fef7d341e0..844612148a34 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -460,6 +460,7 @@ void SwView::SelectShell()
rDispatcher.Push( *m_pShell );
}
m_pShell = new SwTextShell(*this);
+
rDispatcher.Push( *m_pShell );
if ( m_nSelectionType & SelectionType::Table )
{
@@ -667,7 +668,10 @@ void SwView::CheckReadonlyState()
SID_ATTR_PARA_ORPHANS,
SID_ATTR_PARA_MODEL, SID_PARA_DLG,
FN_SELECT_PARA, SID_DEC_INDENT,
- SID_INC_INDENT
+ SID_INC_INDENT,
+ FN_INSERT_TABLE, FN_FORMAT_TABLE_DLG, FN_EXPAND_GLOSSARY,
+ FN_NUM_BULLET_ON, FN_NUM_NUMBERING_ON, FN_SVX_SET_NUMBER,
+ FN_SVX_SET_BULLET, FN_SVX_SET_OUTLINE, SID_AUTOSPELL_CHECK,
};
static bool bFirst = true;
if ( bFirst )
diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx
index 3b640c179eae..fdf8d1f1ea18 100644
--- a/sw/source/uibase/uiview/view0.cxx
+++ b/sw/source/uibase/uiview/view0.cxx
@@ -210,7 +210,8 @@ void SwView::StateViewOptions(SfxItemSet &rSet)
while(nWhich)
{
bool bReadonly = GetDocShell()->IsReadOnly();
- if (bReadonly && nWhich != FN_VIEW_GRAPHIC && nWhich != FN_HIGHLIGHT_CHAR_DF)
+ if (bReadonly && nWhich != FN_VIEW_GRAPHIC && nWhich != FN_HIGHLIGHT_CHAR_DF
+ && nWhich != SID_AUTOSPELL_CHECK)
{
rSet.DisableItem(nWhich);
nWhich = 0;